#!/usr/bin/perl
#
# Reclean a bunch of records
#
#
# Modify a place record
#
use FileTable;
use Validate::Persons;
use POSIX;
use Counter::CGI;
# Counter specific
use ErrorForm;

require "lib/isemail.pl";

$] > 5.008 && binmode(STDOUT, ":utf8"); # set web page output to utf-8
$prefix = "db";

# Parse the entry
$entry = new Counter::CGI;

$persons = FileTable::open("${prefix}/persons", O_RDWR|O_CREAT);

print <<EoF;
Content-type: text/html; charset="utf-8"

<html><head>
</head><body>
Cleaned the records:<br>
EoF
$keys = $entry->param("keys");
for $key (split(" ", $keys)) {
    $rec = $persons->get($key);
    if (!$rec) {
	print "$key - missing<br>\n";
	next;
    }
    $rec->clean();
    $clean = $persons->getclean($key);
    print "$key - placeid $$clean{placeid}<br>\n";
}
# this doesn't work - the adm stuff confuses it...
#$url = $entry->param("back");

print <<EoF;
<br>
Go back by using your "Back" button
</body></html>
EoF

